<?php

declare(strict_types=1);

namespace Service\AuthService;

use Service\BaseService;
use Service\Code\Normal;

class MnAppAuthService extends BaseService
{
    public function getIp($serverParams)
    {
        if (isset($serverParams['http_client_ip'])) {
            return $serverParams['http_client_ip'];
        } elseif (isset($serverParams['http_x_real_ip'])) {
            return $serverParams['http_x_real_ip'];
        } elseif (isset($serverParams['http_x_forwarded_for'])) {
            //部分CDN会获取多层代理IP，所以转成数组取第一个值
            $arr = explode(',', $serverParams['http_x_forwarded_for']);
            return $arr[0];
        } else {
            return $serverParams['remote_addr'];
        }
    }

    /**
     * 登录
     * @param string $mobile
     * @param string $password
     * @param string $js_code
     * @return array
     */
    public function login(string $mobile,string $password,string $js_code)
    {
        $this->auth($mobile,$password,$js_code);
        
    }

    public function auth($mobile,$password)
    {
        if(empty($mobile)){
            return Normal::returnCode(Normal::FAIL,'手机号不能为空');
        }
        if(empty($password)){
            return Normal::returnCode(Normal::FAIL,'密码不能为空');
        }

        
    }
}
